package com.feature.core.rabbitmq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback;

/**
 * 处理消息发送到 RabbitMQ 服务器后的确认回调。它允许你异步获取消息是否成功到达交换机（Exchange）的状态。
 * 
 * @Description:
 * @author wangzhiyue
 * @date 2025/04/29 09:57:32
 */
public class LogConfirmCallback implements ConfirmCallback {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        this.logger.info("消息发送到服务器回调 id={},是否到达交换={},失败原因={}", new Object[] { correlationData.getId(), ack, cause });
    }

}
